package com.wyj.service.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wyj.mapper.YlrcRoleMapper;
import com.wyj.pojo.YlrcRole;
import com.wyj.pojo.YlrcRoleAuthorities;
import com.wyj.service.YlrcRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
* @author mac
* @description 针对表【ylrc_role】的数据库操作Service实现
* @createDate 2022-11-18 21:05:04
*/
@Service
public class YlrcRoleServiceImpl extends ServiceImpl<YlrcRoleMapper, YlrcRole>
implements YlrcRoleService {

    @Autowired
    YlrcRoleMapper ylrcRoleMapper;

    @Override
    public int addRole(YlrcRole ylrcRole) {
        int insert = ylrcRoleMapper.insert(ylrcRole);
        if (insert >= 0) return 1;
        return 0;
    }

    @Override
    public int deleteRole(int id) {
        int delete = ylrcRoleMapper.deleteById(id);
        if (delete >= 0) return 1;
        return 0;
    }

    @Override
    public List<Map<String, Object>> getRoleMenus(int id) {
        return ylrcRoleMapper.getRoleMenus(id);
    }

    @Override
    public int addRoleMenu(YlrcRoleAuthorities ylrcRoleAuthorities) {
//        int i = ylrcRoleMapper.addRoleMenu();
       // if (i >= 0) return 1;
        return 0;
    }

    @Override
    public List<Map<String, Object>> getRoleAndUsers(String username) {
        return ylrcRoleMapper.getRoleAndUsers(username);
    }
}
